package com.onlymarshall.wheresmao.action;

import java.util.List;

import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;

import com.onlymarshall.wheresmao.dao.BillDao;
import com.onlymarshall.wheresmao.dao.DaoFactory;
import com.onlymarshall.wheresmao.model.Bill;

@Results({@Result(name="bills",value="bills.jsp"), 
		@Result(name="bill", value="bills.jsp")})
public class BillAction extends BaseAction  {
	private BillDao billDao;
	private Bill bill;
	@Override
	public void prepare(){
		billDao = DaoFactory.getBillDao();
	}

	@Override
	public String execute() throws Exception {
		List<Bill> bills = billDao.findAll();
		getRequest().setAttribute("bills", bills);
		return "bills";
	}
	
	public String save() throws Exception{
		billDao.save(bill);
		return "bill";
	}

	public Bill getBill() {
		return bill;
	}

	public void setBill(Bill bill) {
		this.bill = bill;
	}

	
}
